package com.zhsm.fuxi.mvp.presenter

import com.hankkin.library.mvp.presenter.RxLifePresenter
import com.hankkin.reading.http.HttpClientUtils
import com.zhsm.fuxi.mvp.contract.InvoiceDetailContract
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by GuZhC on 2018/10/9.
 * describe:
 */
class InvoiceDetailPresenter : RxLifePresenter<InvoiceDetailContract.IView>(), InvoiceDetailContract.IPresenter {

    override fun getInvoiceDetail(id: String) {
        getMvpView().showLoding()
        val map = HashMap<String,Any>()
        map["invoiceId"]= id
        HttpClientUtils.Builder.getPaipiaHttp().getInvoiceDetails(map)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeEx({
                    getMvpView().hideLoding()
                    getMvpView().getInvoiceDetailSucess(it)
                }, {
                    getMvpView().hideLoding()
                    getMvpView().getInvoiceDetailtFail()
                }).bindRxLifeEx(RxLife.ON_DESTROY)
    }
}